import pandas as pd

df = pd.read_csv('过滤.csv', encoding='gbk')

def toRowDf(row):
    rowDf = row.to_frame()
    rowDf = pd.DataFrame(rowDf.values.T, columns = rowDf.index)
    return rowDf

DfMap = {}
for index, row in df.iterrows():
    RID = row['RID']
    if not RID in DfMap.keys():
        print(RID)
        DfMap[RID] = pd.DataFrame(columns=df.columns)

    if DfMap[RID].shape[0]!=0:
        newType = row['TYPE']
        oldType = DfMap[RID].loc[0, 'TYPE']
        if newType!=oldType:
            print(row)
            break
    else:
        DfMap[RID] = pd.concat([DfMap[RID], toRowDf(row)])